﻿using System;
using System.Collections.Generic;
using System.Web.Mvc.Html;
using ControleRepresentante.Logic.Models;
using WebSite.ViewModels.Fields;

namespace WebSite.ViewModels.IndexViewModels
{
    public static class TransportadoraIndexColumns
    {
        public static Guid Nome = new Guid("27313ac2-7256-4171-a283-461e79b71b3f");
    }

    public class TransportadoraIndexViewModel : UsuariosHolderIndexViewModel<Transportadora>
    {
        public TransportadoraIndexViewModel(bool canCreatePedido)
            : base("Transportadoras", canCreatePedido)
        {
        }

        public string NomeBuscaValue { get; set; }

        protected override void RegisterColumns(IndexColumnDefinitionsCollectionWrapper<Transportadora> indexColumnDefinitionsCollectionWrapper)
        {
            indexColumnDefinitionsCollectionWrapper.Register(TransportadoraIndexColumns.Nome, (transportadora, htmlHelper) => htmlHelper.ActionLink(transportadora.Nome, "Details", new { id = transportadora.Id }));
            base.RegisterColumns(indexColumnDefinitionsCollectionWrapper);
        }

        protected override IEnumerable<IField> GetSearchFields()
        {
            List<IField> result = new List<IField>
            {
                new TextBoxField("Nome", "nome", NomeBuscaValue)
            };
            result.AddRange(base.GetSearchFields());
            return result;
        }
    }
}